import { Route } from "@/api/interface/route";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

// 获取所有路由(树形结构)
export const getRouteListApi = () => {
  return http.get<Route.RouteItem[]>(PORT1 + `/admin/route/list`);
};

// 添加路由
export const addRouteApi = (params: Route.RouteParams) => {
  return http.post<Route.RouteItem>(PORT1 + `/admin/route/add`, params);
};

// 更新路由
export const updateRouteApi = (params: Route.RouteParams) => {
  return http.post<boolean>(PORT1 + `/admin/route/update`, params);
};

// 删除路由
export const deleteRouteApi = (params: { FId: string }) => {
  return http.post<boolean>(PORT1 + `/admin/route/delete`, params);
};

// 获取角色拥有的路由
export const getRoleRoutesApi = (params: { FRoleId: string }) => {
  return http.get<Route.RoleRoutleList[]>(PORT1 + `/admin/route/role/`, params);
};

// 更新角色路由权限
export const updateRoleRoutesApi = (params: Route.RoleRouteParams) => {
  return http.post<boolean>(PORT1 + `/admin/route/role/update`, params);
};
